
package com.tanjun.gateway.gatewayservice.config.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import java.util.List;

/**
 * 必须要配置一个消息转换的
 */
@Configuration
public class MessageConvertConfig {
    @Autowired
    private ObjectMapper objectMapper;
    @Bean
    public HttpMessageConverters messageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
        return new HttpMessageConverters(converters);
    }
}
